﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace HomeLibrary
{
  public  class Library
    {
        private LibraryType _libraryData;
        public LibraryType LibraryData
        {
            get { return _libraryData; }
            set { _libraryData = value; }
        }
        public void LoadXmlData(string filename){
            StreamReader str = new System.IO.StreamReader(filename);
            System.Xml.Serialization.XmlSerializer xSerializer = new System.Xml.Serialization.XmlSerializer(typeof(LibraryType));
            LibraryData = (LibraryType)xSerializer.Deserialize(str);
            xSerializer = null;
            str.Close();
        }
        public Library() { }
        public void SaveXMLData(string filename)
        {
           System.Xml.Serialization.XmlSerializer mySerializer = new System.Xml.Serialization.XmlSerializer(typeof(LibraryType));
            // To write to a file, create a StreamWriter object.
            StreamWriter myWriter = new StreamWriter(filename);
            mySerializer.Serialize(myWriter, LibraryData);
        }
    }
}
